<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>thymeleaf向js渲染对象</title>
</head>
<body>
<div>
    <h1>一. thymeleaf向js中渲染对象</h1>
    <article>
        <div id="content"></div>
        <button id="showData">显示thymeleaf渲染的数据</button>
    </article>
</div>
</body>
<script src="/static/jquery-3.4.1.js"></script>
<script th:inline="javascript">
    let jsonObj = JSON.parse([[${data}]]);

    $(function () {
        buttonInit();
    });

    function buttonInit() {
        $('#showData').click(function () {
            console.log(jsonObj, jsonObj.name);
        });
    }

</script>
</html>